package main

import "fmt"

//defer在函数退出return时按先进后出的顺序执行。
func fun() {
	defer fmt.Println("defer1")
	fmt.Println("func....")
	defer fmt.Println("defer2")
}

func main() {
	defer fmt.Println("defer3")
	fun()
	defer fmt.Println("defer4")
}
